#ifndef TICKETBOOKING_H
#define TICKETBOOKING_H

#include <QWidget>
#include <QRunnable>
#include <QElapsedTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class TicketBooking; }
QT_END_NAMESPACE

class TicketBooking : public QWidget
{
    Q_OBJECT

public:
    TicketBooking(QWidget *parent = nullptr);
    ~TicketBooking();

public:
    void run();    //线程入口函数

private slots:
    void on_startBtn_clicked();

    void on_vipBtn_clicked();

    void on_textBrowser_textChanged();

private:
    Ui::TicketBooking *ui;

    bool m_isTicketGrabbing{false};    //是否在抢票中
    int m_res{100};                    //模拟车票资源数
    std::atomic<bool> m_isAbort;       //线程是否退出
    std::atomic<uint32_t> m_number{1};   //助手编号
    std::atomic<bool> m_isVip{false};           //是否是VIP
    QElapsedTimer m_elapsedTimer;               //显示抢票时间定时器
};
#endif // TICKETBOOKING_H
